package com.kedacom.config.resource;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class DefaultConfigurationResource implements ConfigurationResource {
	
	private Properties properties;

	public DefaultConfigurationResource() {
	}

	public DefaultConfigurationResource(String propertiesFile) {
		InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(propertiesFile);
		properties = new Properties();
		try {
			properties.load(inputStream);
		} catch (IOException e) {
			e.printStackTrace();
		}  finally {
			if (inputStream != null) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
	@Override
	public String getValue(String key) {
		String value = properties.getProperty(key);
		return value != null ? value : "";
	}
}
